import { IFeidaoAiNodejsComponent } from '@feidao/web/interfaces';

import render from '@feidao/web/atom/nodejs/render/render';
// import get_menus from '@feidao/web/atom/nodejs/authorization/get-menus';
////////////////////////////////////////////////////////////////////////////////
// import presentations
////////////////////////////////////////////////////////////////////////////////

export default async function na001(fd: IFeidaoAiNodejsComponent, ...args: any[]) {

	// 数据结构
	const data = [{
		"menu_no": "P070004000",
		"menu_name": "首页",
		"parent_no": "",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "index.html"
	}, {
		"menu_no": "P070004001",
		"menu_name": "控件",
		"parent_no": "",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": ""
	}, {
		"menu_no": "P070004001001",
		"menu_name": "WEB+H5",
		"parent_no": "P070004001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": ""
	}, {
		"menu_no": "P070004001001001",
		"menu_name": "轮播图",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000000.html"
	}, {
		"menu_no": "P070004001001002",
		"menu_name": "珊格-容器(1190)",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000001.html"
	}, {
		"menu_no": "P070004001001003",
		"menu_name": "珊格-行",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000002.html"
	}, {
		"menu_no": "P070004001001004",
		"menu_name": "珊格-容器(100%)",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000003.html"
	}, {
		"menu_no": "P070004001001005",
		"menu_name": "饼图",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000005.html"
	}, {
		"menu_no": "P070004001001006",
		"menu_name": "柱状图&折线图",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000006.html"
	}, {
		"menu_no": "P070004001001007",
		"menu_name": "折线图",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000007.html"
	}, {
		"menu_no": "P070004001001008",
		"menu_name": "柱状图",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000008.html"
	}, {
		"menu_no": "P070004001001009",
		"menu_name": "甘特图",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000009.html"
	}, {
		"menu_no": "P070004001001010",
		"menu_name": "开关按钮",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000010.html"
	}, {
		"menu_no": "P070004001001011",
		"menu_name": "环状图",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000011.html"
	}, {
		"menu_no": "P070004001001012",
		"menu_name": "评分",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000012.html"
	}, {
		"menu_no": "P070004001001013",
		"menu_name": "弹窗",
		"parent_no": "P070004001001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "wh000013.html"
	}, {
		"menu_no": "P070004001002",
		"menu_name": "WEB控件",
		"parent_no": "P070004001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": ""
	}, {
		"menu_no": "P070004001002001",
		"menu_name": "折叠树",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000001.html"
	}, {
		"menu_no": "P070004001002002",
		"menu_name": "百度地图v3.0",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000002.html"
	}, {
		"menu_no": "P070004001002003",
		"menu_name": "日历控件",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000004.html"
	}, {
		"menu_no": "P070004001002004",
		"menu_name": "下拉多选框",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000005.html"
	}, {
		"menu_no": "P070004001002005",
		"menu_name": "日期选择",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000006.html"
	}, {
		"menu_no": "P070004001002006",
		"menu_name": "文件上传",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000007.html"
	}, {
		"menu_no": "P070004001002007",
		"menu_name": "时间选择",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000008.html"
	}, {
		"menu_no": "P070004001002008",
		"menu_name": "a标签分页",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000009.html"
	}, {
		"menu_no": "P070004001002009",
		"menu_name": "按钮分页",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000010.html"
	}, {
		"menu_no": "P070004001002010",
		"menu_name": "珊格-列",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000011.html"
	}, {
		"menu_no": "P070004001002011",
		"menu_name": "相对于浏览器窗口定位的盒子",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000012.html"
	}, {
		"menu_no": "P070004001002012",
		"menu_name": "富文本框",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000013.html"
	}, {
		"menu_no": "P070004001002013",
		"menu_name": "天气预报",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000014.html"
	}, {
		"menu_no": "P070004001002014",
		"menu_name": "百度地图v2.0",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000015.html"
	}, {
		"menu_no": "P070004001002015",
		"menu_name": "七牛云上传",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000016.html"
	}, {
		"menu_no": "P070004001002016",
		"menu_name": "商城放大镜",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000017.html"
	}, {
		"menu_no": "P070004001002017",
		"menu_name": "下拉搜索框",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000018.html"
	}, {
		"menu_no": "P070004001002018",
		"menu_name": "画板",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000019.html"
	}, {
		"menu_no": "P070004001002019",
		"menu_name": "倒计时",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000020.html"
	}, {
		"menu_no": "P070004001002020",
		"menu_name": "查看全部",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000021.html"
	}, {
		"menu_no": "P070004001002021",
		"menu_name": "轮播图",
		"parent_no": "P070004001002",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "w000022.html"
	}, {
		"menu_no": "P070004001003",
		"menu_name": "H5控件",
		"parent_no": "P070004001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": ""
	}, {
		"menu_no": "P070004001003001",
		"menu_name": "划动列表",
		"parent_no": "P070004001003",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "h000000.html"
	}, {
		"menu_no": "P070004001003002",
		"menu_name": "划动列表-简易版",
		"parent_no": "P070004001003",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "h000001.html"
	}, {
		"menu_no": "P070004001003003",
		"menu_name": "滑动选择器",
		"parent_no": "P070004001003",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "h000002.html"
	}, {
		"menu_no": "P070004001003004",
		"menu_name": "珊格-列",
		"parent_no": "P070004001003",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "h000003.html"
	}, {
		"menu_no": "P070004001003005",
		"menu_name": "列表左滑抽屉",
		"parent_no": "P070004001003",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "h000004.html"
	}, {
		"menu_no": "P070004001004",
		"menu_name": "IE控件",
		"parent_no": "P070004001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "ie.html"
	}, {
		"menu_no": "P070004002",
		"menu_name": "问题汇总",
		"parent_no": "",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "questions.html"
	}, {
		"menu_no": "P070004003",
		"menu_name": "登录",
		"parent_no": "",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": ""
	}, {
		"menu_no": "P070004003001",
		"menu_name": "WEB登录",
		"parent_no": "P070004003",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": ""
	}, {
		"menu_no": "P070004003001001",
		"menu_name": "WEB登录-1",
		"parent_no": "P070004003001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "login.html"
	}, {
		"menu_no": "P070004003001002",
		"menu_name": "WEB登录-2",
		"parent_no": "P070004003001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "login2.html"
	}, {
		"menu_no": "P070004003001003",
		"menu_name": "WEB登录-3",
		"parent_no": "P070004003001",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "login3.html"
	}, {
		"menu_no": "P070004003002",
		"menu_name": "H5登录",
		"parent_no": "P070004003",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "h5-login.html"
	}, {
		"menu_no": "P070004004",
		"menu_name": "注册",
		"parent_no": "",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "register.html"
	}, {
		"menu_no": "P070004005",
		"menu_name": "导出",
		"parent_no": "",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "export.html"
	}, {
		"menu_no": "P070004006",
		"menu_name": "验证码",
		"parent_no": "",
		"icon": "icon-menu1",
		"priority": 1,
		"is_show": true,
		"background": "",
		"package_url": "captcha.html"
	}];
	// 数据处理
	const t = (p: any) => {
		return data.filter((d: any) => {
			return d.is_show && (d.parent_no === p);
		});
	};
	const d1 = data.filter((d: any) => {
		d.c = t(d.menu_no);
		return d.is_show && (d.parent_no === '');
	});

	let r = ``;
	// tslint:disable-next-line:no-shadowed-variable
	const t1 = (data: any, level: number) => {
		data.forEach((d: any) => {
			//  data=` + encodeURIComponent(JSON.stringify(d)) + `
			// const bc = d.color ? 'background-color: ' + d.color + ';' : '';
			if (d.c.length === 0) {
				let str = ``;
				str = `<div name="div` + level + `" class="menu` + level + `" style="display: none;">
					<div name="xz" class="bg" flag="0" data-feidao-l="` + level + `" data-feidao-actions="click:eu-001,mouseout:eu-002,mouseover:eu-003">
					<a href="` + (d.package_url ? d.package_url : 'javascript:void(0)') + `">
						<div class="opacity" style="height: 44px;width: 100%;">
							<i class="child_icon iconfont ` + d.icon + `" style="width: 44px;height:44px;line-height:44px;float: left;"></i>
							<span class="menu` + level + `_name" style="height: 44px;line-height: 44px;">` + d.menu_name + `</span>
						</div>
						</a>
					</div>
				</div>`;
				r += str;
			} else {
				let str = ``;
				str = `<div name="div` + level + `" class="menu` + level + `" style="display: none;">
					<div name="xz" class="bg" flag="0" data-feidao-l="` + level + `" data-feidao-actions="click:eu-001,mouseout:eu-002,mouseover:eu-003">
					<a href="` + (d.package_url ? d.package_url : 'javascript:void(0)') + `">
						<div class="opacity" style="height: 44px;width: 100%;">
							<i class="child_icon iconfont ` + d.icon + `" style="width: 44px;height:44px;float: left;"></i>
							<span class="menu` + level + `_name" style="height: 44px;line-height: 44px;">` + d.menu_name + `</span>
						</div></a>
					</div><div data-feidao-level="` + (level + 1) + `">`;
				r += str;
				t1(d.c, (level + 1));
			}
		});
		r += `</div></div>`;
	};

	// 第一级目录
	d1.forEach((d: any) => {
		const bc = d.background ? 'background: ' + d.background + ';' : '';
		//  data=` + encodeURIComponent(JSON.stringify(d)) + `
		if (d.c.length === 0) {
			r += `<div data-feidao-level="1">
				<div class="menu1 bg" style="height:44px;line-height: 44px;" flag="0" data-feidao-l="1" data-feidao-actions="click:eu-001,mouseout:eu-002,mouseover:eu-003">
				<a href="` + (d.package_url ? d.package_url : 'javascript:void(0)') + `">
				<span class="left_icon" style="width: 44px;height:44px;">
					<i class="iconfont icon ` + d.icon + `" style="width: 44px;height:44px;"></i>
					<span class="color" style="left: -44px;width: 44px;height:44px;position: absolute;` + bc + `" data-feidao-s="s"></span>
				</span>
				<span class="menu_name" style="width: 144px;height: 44px;">` + d.menu_name + `</span>
				<i class="flod_icon" style="line-height: 44px;right: 37px;margin-top: -10px;"></i></a>
		</div>`;
		} else {
			r += `<div data-feidao-level="1">
				<div class="menu1 bg" style="height:44px;line-height: 44px;" flag="0" data-feidao-l="1" data-feidao-actions="click:eu-001,mouseout:eu-002,mouseover:eu-003">
				<a href="` + (d.package_url ? d.package_url : 'javascript:void(0)') + `">
				<span class="left_icon" style="width: 44px;height:44px;">
					<i class="iconfont icon ` + d.icon + `" style="width: 44px;height:44px;"></i>
					<span class="color" style="left: -44px;width: 44px;height:44px;position: absolute;` + bc + `" data-feidao-s="s"></span>
				</span>
				<span class="menu_name" style="width: 144px;height: 44px;">` + d.menu_name + `</span>
				<i class="flod_icon" style="line-height: 44px;right: 37px;margin-top: -10px;"><img data-feidao-id="icon" style="margin-top: 20px;display: inline-block;" src="../images/jt_button.png"></i></a>
		</div><div data-feidao-level="2">`;
			t1(d.c, 2);
		}
		r += '</div>';
	});

	render(fd.data.node, '', r, 'P01');
}
